//
//  QQTimeTool.swift
//  QQ音乐
//
//  Created by 曹均华 on 16/6/5.
//  Copyright © 2016年 曹均华. All rights reserved.
//

import UIKit

class QQTimeTool: NSObject {

    class func getFormatTime(timeInterval: NSTimeInterval) -> String {
    
        let min = Int(timeInterval) / 60
        let sec = Int(timeInterval) % 60
        
        let timeStr = String(format: "%02d:%02d", min, sec)
        
        return timeStr
        
    }
    
    class func getTimeInterval(formatTime: String) -> NSTimeInterval {
        
        // 00:00.89 == formatTime
        
        let minSec = formatTime.componentsSeparatedByString(":")
        if minSec.count == 2 {
            let min = NSTimeInterval(minSec[0]) ?? 0
            let sec = NSTimeInterval(minSec[1]) ?? 0
            return min * 60 + sec
        }
        
        
        return 0
        
    }
    
    
    
    
}
